package service.impl;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import factory.SimpleDaoFactory;
import pojo.News;
import service.NewsService;

public class NewsServiceImpl implements NewsService {

//    // 调用数据访问层接口的save方法
    NewsDao newsDao = SimpleDaoFactory.getInstance("mysql");

    @Override
    public void save(News news) {
        newsDao.save(news);
    }

    //所依赖的NewsDao
    private NewsDao dao;
    public void setDao(NewsDao dao) {
        this.dao = dao;
    }

    public void  addNews(News news) {
        // 调用newsDao的方法保存新闻信息
        dao.save(news);
    }
}
